//
//  HomeHeadCell.m
//  meituan
//
//  Created by huiwenjiaoyu on 15/12/15.
//  Copyright © 2015年 Rick. All rights reserved.
//

#import "HomeHeadCell.h"
#import "RXButton.h"
#import "UIImageView+AFNetworking.h"

@interface HomeHeadCell()

@property (nonatomic, strong) RXButton *iconBtn;

@end

@implementation HomeHeadCell

- (RXButton *)iconBtn
{
    if (_iconBtn == nil) {
        _iconBtn = [[RXButton alloc] initWithFrame:self.contentView.bounds];
        [_iconBtn addTarget:self action:@selector(iconDidSelected:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_iconBtn];
    }
    return _iconBtn;
}


- (void)iconDidSelected:(UIControl *)control
{
    [[NSNotificationCenter defaultCenter] postNotificationName:kcategryNotificationIdentifier object:nil userInfo:@{@"controlTag":@(control.tag),@"name":self.iconInfo.name}];
    NSLog(@"%li",control.tag);
}

- (void)setIconInfo:(CategoryModel *)iconInfo
{
    if (_iconInfo != iconInfo) {
        _iconInfo = iconInfo;
        [self.iconBtn.imageView setImageWithURL:[NSURL URLWithString:_iconInfo.iconUrl]];
        self.iconBtn.label.text = _iconInfo.name;
    }
}

- (void)setControlTag:(NSInteger)controlTag
{
    if (_controlTag != controlTag) {
        _controlTag = controlTag;
        self.iconBtn.tag = self.controlTag;
    }
}

@end
